import request from '@/utils/request'

export const checkLogin = (data) => {
  return request({
    method: 'post',
    url: '/users/checkLogin',
    data
  })
}

export const checkAccountRepeat = (data) => {
  return request({
    method: 'post',
    url: '/users/repeat',
    data
  })
}

export const addAccount = (data) => {
  return request({
    method: 'post',
    url: '/users/add',
    data
  })
}

export const getAccountList = (currentPage, pageSize) => {
  return request({
    method: 'get',
    url: `/users/list?currentPage=${currentPage}&pageSize=${pageSize}`
  })
}

// 根据id删除数据
export const delAccount = (id) => {
  return request({
    method: 'get',
    url: '/users/del?id=' + id
  })
}

// 批量删除数据需要传递 ids
export const delAccountBatchdel = (data) => {
  return request({
    method: 'post',
    url: '/users/batchdel',
    data
  })
}

// 编辑账号
export const editAccount = (data) => {
  return request({
    method: 'post',
    url: '/users/edit',
    data
  })
}

// 检查旧密码
export const checkOldPwd = (oldPwd) => {
  return request({
    method: 'get',
    url: '/users/checkoldpwd?oldPwd=' + oldPwd
  })
}

// 更新密码
export const editPwd = (data) => {
  return request({
    method: 'post',
    url: '/users/editpwd',
    data
  })
}

// 更新密码
export const getUserInfo = () => {
  return request({
    method: 'get',
    url: '/users/info'
  })
}

// 更新头像
export const avatarEdit = (imgUrl) => {
  return request({
    method: 'get',
    url: '/users/avataredit?imgUrl=' + imgUrl
  })
}
